<style>
    .page{background-color: white !important;}
    .zan-btn .shoucang-m {display: none;}
    .upload-imgs{display: none;}
    .clearfix:after { clear: both;}
    .clearfix:before, .clearfix:after { content: " "; display: table;}
    .art-wrap{background-color: white}
    .article-wrapper{background-color: white;}
    .article-wrapper .article-header {padding: 10px 0;border: 1px solid #eee; border-bottom: 3px solid #0f5489; background-color: #f7f7f7;}
    .article-header .title {padding-left: 30px; float: left;}
    .title h1{font-size: 16px;}
    .title h1 a {color: #0f5489}
    .title em {font-style: normal}
    .article-header .article-info {float: right; font-size: 12px; color: #999; line-height: 25px; margin-right: 10px;}
    .article-info span.num {color: #F26C4F}
    .article-info span.pipe {margin: 0 5px}
    .article {display: flex;margin: 15px 0 ;border-bottom: 1px solid #eee; border-right: 1px solid #eee; border-top: 1px solid #eee;}
    .article .author-info{width: 188px; background-color: #f7f7f7; border:1px solid #eee;}
    .author-info .author-name{text-align: center; margin: 5px 0;}
    .author-name a{color: #0f5489;}
    .author-img{width: 188px; margin: 10px 0;}
    .author-img img {display: block;margin: 0 auto;}
    .author-info span.grade {display: block; text-align: center; color: orangered;}
    .post-num{padding: 20px; text-align: center;}
    .post-num span{color: #999; font-size: 12px;}
    .article .article-r{flex: 1; padding: 10px 20px; position: relative;}
    .issuing-time{color: #999; font-size: 13px; margin: 10px 0;}
    .issuing-time img, .issuing-time span {vertical-align: middle;}
    .article-content{min-height: 200px;min-width:200px;}
    .article-content img{width: auto; height: auto;max-width: 100%;max-height: 100%}
    .article-content iframe{max-width: 100%;max-height: 100%}
    /*.article-content embed{width: 100%;height: 100%}*/
    .zan-btn{text-align: center;}
    .zan-btn a{display: inline-block; background-color: #ff8432; height: 78px;width: 78px; position: relative ;border-radius: 50%;}
    .zan-btn a img, .zan-btn a span {display: block; color: white; position: absolute;}
    .zan-btn a img {top: 12px; right: 25px;}
    .zan-btn a span{bottom: 12px;right: 34px;}
    .zan-person{max-height: 100px; width: 577px;text-align: center; margin: 20px auto;}
    .reply-person {position: absolute; right: 25px; bottom: 5px; color: #0f5489; font-size: 13px;}
    #m-editor{display: none;}
    .m-reply-header{display: none;}
    @media (max-width: 1000px) {
        .article{margin: 0;}
        .article-r{}
        .article-header{display: none!important;}
        .menu-info-img {max-width: 36px !important;min-height: 36px !important;}
        .m-article-header{  display: block !important;  padding: 5px; margin-bottom: 5px ; font-size: 14px;  line-height: 120%;  text-align: left;  border-bottom: 5px solid #2d6987;  overflow: auto;}
        .m-article-header headimgurl{float: right;}
        .m-article-header a {color: #778087;  text-decoration: none;  word-break: break-all;}
        .m-article-header span.chevron{font-family: "Lucida Grande";  font-weight: 500;}
        .m-article-header h1{font-size: 18px;  font-weight: 500;  line-height: 140%;  margin: 5px 0px 7px 0px;  padding: 0px;}
        .m-article-header small{color: #999;}
        .article .author-info{display: none}
        .m-reply-header{display: block;}
        .issuing-time{display: none!important;}
        .m-reply-header small{color: #999;line-height: 36px; vertical-align: top; display: inline-block;}
        .m-reply-header headimgurl{display: inline-block;}
        #editor{display: none;}
        #m-editor{display: block;}
        #m-editor #m-editor-content img {width: 100px; height: auto;}
        #m-editor #m-editor-content {overflow-x: auto;}
        #m-editor textarea{width: 100%;}
        .editor-m{width: 100%!important;}
        .article-content img {width: auto; height: auto;max-width: 100%;max-height: 100%}
        .upload-imgs{display: block !important;}
        .zan-btn #fabulous {vertical-align: middle;}
        .zan-btn .shoucang-m {vertical-align: middle;display: inline-block;}
    }
    @media (min-width: 1000px){
        .menu-info-img {min-height: 120px!important; }
    }
    .m-article-header{display: none}
    /*回复样式*/
    .reply {border-top: 3px solid #0f5489; border: 1px solid #e9e9e9;  display: flex; margin-top: 10px;}
    .editor-wrap {    flex: 1;  padding: 25px;}
    .reply-btn a{  float: right;  margin-right: 0;  height: 30px;  background: #f60;  color: white;  font-size: 14px;  vertical-align: middle;  -moz-box-shadow: 0 1px 0 #E5E5E5;  -webkit-box-shadow: 0 1px 0 #E5E5E5;  box-shadow: 0 1px 0 #E5E5E5;}
    .reply-btn strong{    line-height: 30px;  font-weight: 700;  padding: 0 10px;}
    /* table 样式 */
    table {  border-top: 1px solid #ccc;  border-left: 1px solid #ccc;  }
    table td,
    table th { border-bottom: 1px solid #ccc;  border-right: 1px solid #ccc;  padding: 3px 5px;  }
    table th {  border-bottom: 2px solid #ccc;  text-align: center;  }
    /* blockquote 样式 */
    blockquote {  display: block;  border-left: 8px solid #d0e5f2;  padding: 5px 10px;  margin: 10px 0;  line-height: 1.4;  font-size: 100%;  background-color: #f1f1f1;  }
    /* code 样式 */
    code {  display: inline-block;  *display: inline;  *zoom: 1;  background-color: #f1f1f1;  border-radius: 3px;  padding: 3px 5px;  margin: 0 3px;  }
    pre code {  display: block;  }
    /* ul ol 样式 */
    ul, ol {  margin: 10px 0 10px 20px;  }
    /**/
    .chaozuo{float: left;margin-left: 20px; color: gainsboro;font-size: 14px;}
    .chaozuo a{vertical-align: middle;margin-right: 10px;color: #0f5489;}
    .m-chaozuo{padding: 5px;}
    .m-chaozuo a {margin-right: 5px;}

    /*                         分页按钮样式                  */
    .page-wrap{text-align: center}
    .pagination{display: inline-block;padding-left: 0;margin: 20px 0;border-radius: 4px;}
    .pagination li {display: inline-block;}
    .pagination li a {position: relative;float: left;padding: 6px 12px;margin-left: -1px;line-height: 1.42857143;color: #337ab7;text-decoration: none;background-color: #fff; border: 1px solid #ddd;}
    .pagination li span {position: relative;float: left;padding: 6px 12px;margin-left: -1px;line-height: 1.42857143;color: #333;text-decoration: none;background-color: #fff; border: 1px solid #ddd;}
    .pagination>li:first-child>a{margin-left: 0;border-top-left-radius: 4px;border-bottom-left-radius: 4px;}
    .pagination>li:last-child>a{border-top-right-radius: 4px;  border-bottom-right-radius: 4px;}
    .menu-info-img{    width: 100%;  background: #f7f7f7 url(//api.hongyanche.com/_hongyanche/material/logo-3.png) center no-repeat;  background-size: cover;}
</style>

<div class="container art-wrap">
    <div class="article-wrapper">
        <div id="forum-detail" class="bc-info no-init" data-port="http://api.hongyanche.com/forum/getinfo">
            <input autocomplete='off' class='hidden' id='forum_id' name='forum_id' />
            <div class="article-header clearfix">
                <div class="title">
                    <h1 id="post-title">
                        <a href="/home#forum">论 坛</a> >
                        <a href="javascript:void(0)" class="labelname"><label_name info=1></label_name></a>
                        <label_id info=1 class="hidden"></label_id>
                        <em> > </em>
                        <span style="float: right"> <title info=1></title></span>
                    </h1>
                </div>
                <moderators info=d>
                    <div class="chaozuo">
                        <highlight info=none>
                            <a href="javascript:void (0)" onclick="featuresButton('good')">加精</a>
                        </highlight>
                        <highlight info=d>
                            <a href="javascript:void (0)" onclick="featuresButton('ugood')">取消精华</a>
                        </highlight>
                        <top info=none>
                            <a href="Javascript:void(0)" onclick="featuresButton('top')">置顶</a>
                        </top>
                        <top info=d>
                            <a href="Javascript:void(0)" onclick="featuresButton('utop')">取消置顶</a>
                        </top>
                        <a href="javascript:void (0)" onclick="featuresButton('delete')">删除</a>
                    </div>
                </moderators>
                <div class="article-info chaozuo">
                    <moderators info=d>
                        <!--<a href="javascript:void (0)" onclick="featuresButton('move')" >转移板块</a>-->
                        <apply info=d>
                            转移板块:
                            <select class="labels">
                                <option value="">当前板块</option>
                            </select>
                        </apply>
                        <apply info=d><a href="javascript:void (0)" onclick="featuresButton('review')" >通过</a></apply>
                        <apply info=d><a href="javascript:void (0)" onclick="featuresButton('reject')">拒绝</a></apply>
                    </moderators>
                    <span class="text">查看:</span>
                    <span class="num"><browse info=1></browse></span>
                    <span class="pipe">|</span>
                    <span class="text">回复:</span>
                    <span class="num"><reply_amount info=1></reply_amount></span>
                    <span class="pipe">|</span>
                    <a class="shoucang collection" href="javascript:void (0)">收藏帖子</a>
                </div>
            </div>
            <div id="article-detail" class="article">
                <div class="author-info">
                    <div class="author-name">
                        <a class="user-space" href="javascript:void (0)"><user_name info=1></user_name></a>
                        <user_id info=1 class="hidden"></user_id>
                    </div>
                    <a class="user-space" href="javascript:void (0)"><div class="author-img">
                        <headimgurl info=none><img class='menu-info-img'  style="height:120px;width: 120px;"/></headimgurl>
                        <headimgurl info=d> <headimgurl info=i><img id="post-ava" class='menu-info-img'  style="height:120px;width: 120px;"/></headimgurl></headimgurl>
                    </div></a>
                    <user_id info=1 class="hidden"></user_id>
                    <span class="grade">
                    <empirical_value info=1></empirical_value>
                    </span>
                    <moderator info=d>
                        <span class="grade">
                            <img src="/_hongyanche/material/banzu.png" alt="">
                        </span>
                    </moderator>
                    <div class="post-num">
                        <span>帖子</span>
                        <span><forum_amount info=1></forum_amount></span>
                    </div>
                </div>
                <div class="article-r">
                    <div class="m-article-header">
                        <headimgurl info=i><img class='menu-info-img'/></headimgurl>
                        <a href="http://api.hongyanche.com/home#forum">论坛</a>
                        <span class="chevron">&nbsp;›&nbsp;</span>
                        <label_name info=1></label_name>
                        <h1><title info=1></title></h1>
                        <moderators info=d>
                            <div class="m-chaozuo">
                                <apply info=none>
                                    <highlight info=none>
                                        <a href="javascript:void (0)" onclick="featuresButton('good')">加精</a>
                                    </highlight>
                                    <highlight info=d>
                                        <a href="javascript:void (0)" onclick="featuresButton('ugood')">取消精华</a>
                                    </highlight>
                                    <top info=none>
                                        <a href="Javascript:void(0)" onclick="featuresButton('top')">置顶</a>
                                    </top>
                                    <top info=d>
                                        <a href="Javascript:void(0)" onclick="featuresButton('utop')">取消置顶</a>
                                    </top>
                                </apply>
                                <apply info=d>
                                    <span style="color:#999;font-size:12px;">转移板块:</span>
                                    <select class="labels">
                                        <option value="">当前板块</option>
                                    </select>
                                </apply>
                                <apply info=d><a href="javascript:void (0)" onclick="featuresButton('review')" >通过</a></apply>
                                <apply info=d><a href="javascript:void (0)" onclick="featuresButton('reject')">拒绝</a></apply>
                                <a href="javascript:void (0)" onclick="featuresButton('delete')">删除</a>
                            </div>
                        </moderators>
                        <small>
                            <user_name info=1></user_name> 发表于: <create_time info=1></create_time>
                        </small>
                    </div>
                    <div class="issuing-time">
                        <span>发表于 <create_time info=1></create_time></span>
                    </div>
                    <div class="article-content">
                        <content info=1></content>
                    </div>
                    <div class="zan-btn">
                        <a href="javascript:void(0)" id="fabulous">
                            <img src="https://s.kcimg.cn/bbs/static/image/common/rec_add.png" alt="">
                            <span><fabulous info=1>1</fabulous></span>
                        </a>
                        <a href="javascript:void(0)" class="collection shoucang-m" style="background: cadetblue">
                            <img src="/_hongyanche/material/shoucang.png" alt="">
                            <span style="right: 24px;">收藏</span>
                        </a>
                    </div>
                </div>
            </div>
            <div id="huifu-list">

            </div>
            <div class="page-wrap">
                <ul id="page-btn" class="pagination"></ul>
            </div>
        </div>
    </div>
    <div class="reply">
        <div class="editor-wrap">
            <div id="editor">
                <p>评论...</p>
            </div>
            <div id="m-editor">
                <!--<textarea name="" id="m-editor-content"  rows="10"></textarea>-->
                <div contenteditable="true" id="m-editor-content" style="width: 100%; height: 200px; border: 1px solid #ddd;"></div>
            </div>
            <div class="upload-imgs" >
                <div class="weui-uploader__input-box" style="width: 44px;height: 44px">
                    <input type="file" class="weui-uploader__input" id="mupload">
                </div>
            </div>
            <div class="reply-btn clearfix">
                <a id="submit-reply" href="javascript:void (0)" style="margin-top: 10px;"><strong>发表评论</strong></a>
            </div>
        </div>
    </div>
</div>


<script>
    var postID = GET('forum_id');
    INFO.reload('#forum_id',{forum_id: GET('forum_id')});
    /**
     * @param {[uri]} [要获取数据的接口]
     * @return {Promise}
     * */
    var getData = function (uri) {
        return new Promise(function(resolve, reject) {
                $.ajax({
                url: uri,
                type: 'POST',
                data: {
                    replys: 1,
                    forum_id: GET('forum_id')
                },
                    xhrFields:{
                        withCredentials:true
                    },
                success: function (data) {
                    resolve(data)
                },
                error: function (err) {
                    reject(err)
                }
            })
    })
    };
    /**
     * 获取选中页面的数据
     * @param {uri} {要获取数据的接口}
     * @param {[page]} {选中的页数}
     * @return {Promise}
     * */
    var getPageData = function (uri,page) {
        return new Promise(function(resolve, reject) {
                $.ajax({
                url: uri,
                type: 'POST',
                data: {
                    replys: 1,
                    forum_id: GET('forum_id'),
                    page: page
                },
                    xhrFields:{
                        withCredentials:true
                    },
                success: function (data) {
                    resolve(data)
                },
                error: function (err) {
                    reject(err)
                }
            })
    })
    };
    // 创建回复列表
    var createDom = function (data, dom) {
        var htmlStr = '';
        var deleteHTML = '';
        var adminHTML = '';
        var headimgurl = '';
        for (var i =0; i<data.length; i++) {
            var huifuStr = '';
            if (data[i].replys) {
                for (var j =0; j<data[i].replys.length;j++) {
                    huifuStr += `<p style="font-size: 14px"><span style="color: #00a0e9; cursor: pointer;">@${data[i].replys[j].user_name}:</span>${data[i].replys[j].content}</p>`
                }
            }
            if (data[i].moved) {
                deleteHTML = `<a data-id="${data[i].reply_id}" class="delete" href="javascript:void(0)" >删除</a>`;
            }else{
                deleteHTML = ``;
            }
            if (data[i].moderator) {
                adminHTML = `<img src="/_hongyanche/material/banzu.png" alt="">`
            }else{
                adminHTML = ``;
            }
            if (data[i].headimgurl) {
                headimgurl = `<a class='user-space' href='javascript:void(0)' user-id="${data[i].user_id}"><img src="${data[i].headimgurl}" alt="" style="height:120px;width: 120px;"/></a>`
            }else{
                headimgurl = `<a class="user-space" href="javascript:void(0)" user-id="${data[i].user_id}"><img class='menu-info-img'  style="height:120px;width: 120px;"/></a>`;
            }
            htmlStr += `
                <div class="article">
                    <div class="author-info">
                        <div class="author-name">
                            <a user-id="${data[i].user_id}" class="user-space" href="javascript:void(0)">${data[i].user_name}</a>
                        </div>
                        <div class="author-img">
                            ${headimgurl}
                        </div>

                        <span class="grade">
                            ${data[i].empirical_value}
                        </span>
                        <span class="grade">
                            ${adminHTML}
                        </span>
                        <div class="post-num">
                            <span>帖子</span>
                            <span>${data[i].forum_amount}</span>
                        </div>
                    </div>
                    <div class="article-r">
                        <div class="m-reply-header">
                            <img class='menu-info-img' src="${data[i].headimgurl}"/>
                            <small>
                                ${data[i].user_name} 发表于: ${data[i].create_time}
                            </small>
                        </div>
                        <div class="issuing-time">
                            <img src="https://s.kcimg.cn/bbs/static/image/common/online_member.gif" alt="">
                            <span>发表于 ${data[i].create_time}</span>
                        </div>
                        <div class="article-content">
                            ${data[i].content}
                        </div>
                        <div>
                            ${huifuStr}
                        </div>
                        <div style="margin-bottom: 10px;"></div>
                        <div class="reply-person">
                            ${deleteHTML}
                            <a class="reply-person-btn" href="javascript:void (0)">回复</a>
                        </div>
                        <div class="reply-box" style="display: none;">
                            <textarea class="editor-m" style="width: 500px" rows="8"></textarea>
                            <a pid="${data[i].reply_id}" class="submit-reply weui-btn weui-btn_primary" style="display: inline-block" href="javascript:void (0)">发表回复</a>
                        </div>
                    </div>
                </div>`;
            $(dom).html(htmlStr);
        };
    };

    ;(function (w, u) {
        var thisUrl = w.location.href;
        var forumId = GET('forum_id');
        $('#forum_id').val(GET('forum_id'));
        var E = window.wangEditor;
        var editor = new E('#editor');
        editor.customConfig.uploadImgServer = '/upload/forum_article';
        editor.customConfig.uploadFileName = '0';
        editor.customConfig.uploadImgParams = false;
        editor.create();
        // 回复帖子 reply
        $('.reply').on('click','#submit-reply' ,function () {
            var content = editor.txt.html();
            var content2 = editor.txt.text();
            var mContent = $('#m-editor-content').html();
            var content_pre = /<p><br><\/p>/;
            if (mContent) {
                content = mContent;
            }
            if ((!mContent && content_pre.test(content)) && !content2) {
                return TOAST.wran('请输入内容', ' ', 1);
            }
            $.ajax({
                url: '/forum/reply',
                type: 'POST',
                data: {
                    forum_id: forumId,
                    content: content,
                    url: thisUrl
                },
                xhrFields:{
                    withCredentials:true
                },
                success: function (e) {
                    if ($('#m-editor-content').val()) {
                        $('#m-editor-content').val('');
                    }
                    if(e.state) {
//                        INFO.reload('#forum_id', {forum_id: GET('forum_id')});
                        w.location.reload();
                        editor.txt.clear()
                    }else{
                        return TOAST.wran(e.errormsg, ' ', 2);
                    }
                },
                error: function () {
                    return TOAST.wran('回复失败', ' ', 2);
                }
            })
        });

        // 论坛回复
        try {
            getData('/forum/getinfo').then(function(data) {
                var page = data.page;
            var datas = data.data.info;
            var page = data.page;
            $('#page-btn').html(page);
            createDom(datas, '#huifu-list');
        });
        }
        catch (e) {
            console.log(e)
        }
    })(window, undefined);
    $('body').on('click','#fabulous',function () {
        $.ajax({
            url:'/forum/fabulous',
            data:{forum_id:GET('forum_id')},
            xhrFields:{
                withCredentials:true
            },
            success:function (e) {
                if(e.state){
                    $('#fabulous').find('span').html(e.data.fabulous);
                }else{
                    return TOAST.wran(e.errormsg, ' ', 2);
                }
            },
            error: function() {
                TOAST.wran('网络错误', ' ', 1);
            }
        })
    });
    // reply-person
    $('#huifu-list').on('click', '.reply-person-btn', function () {
        $('.reply-box').hide();
        $(this).parent().next().show();
    });
    // 回复楼中楼
    $('#forum-detail').on('click','.submit-reply', function () {
        var page = $('.selected').text();
        var replyContent = $(this).prev().val();
        var replyID = $(this).attr('pid');
        var forumId = GET('forum_id');
        var thisUrl = window.location.href;
        if (replyContent) {
            $.ajax({
                url: '/forum/reply',
                type: "POST",
                data: {
                    pid: replyID,
                    forum_id: forumId,
                    content: replyContent,
                    url: thisUrl
                },
                xhrFields:{
                    withCredentials:true
                },
                success: function () {
                    getPageData('/forum/getinfo', page).then(function(data) {
                        if (page > 1) {
                        $('#article-detail').hide();
                    } else {
                        $('#article-detail').show();
                    }
                    var datas = data.data.info;
                    createDom(datas, '#huifu-list');
                });
                },
                error: function() {
                    TOAST.wran('服务器繁忙', ' ', 1);
                }
            });
        } else {
            return TOAST.wran("请输入内容", ' ', 2);
        }
    });

    $('body').on('click','.collection' ,function () {
        var forumId = GET('forum_id');
        var url = window.location.href;
        $.ajax({
            url: '/collect/add',
            type: 'POST',
            data: {
                forum_id: forumId,
                'class': 2,
                url: url
            },
            xhrFields:{
                withCredentials:true
            },
            success: function (data) {
                if(data.state) {
                    return TOAST.success('收藏成功',' ',1)
                }else{
                    return TOAST.wran(data.errormsg,' ',1)
                }
            }
        })
    });
    $('#forum-detail').on('click', '.labelname',function () {
        var labelId = $(this).next().text();
        window.location.href = '/home?label_id='+ labelId +'#forum_page';
    });


    // 功能按钮
    function featuresButton(e) {
        var labelID = $('.labelname').next().text();
        var forumId = GET('forum_id');
        if (e == 'good') {
            var good = confirm('是否设置精华?');
            if(good) {
                $.ajax({
                    url: '/forum/highlight',
                    type: "POST",
                    data: {
                        forum_id: forumId,
                        highlight: 1
                    },
                    xhrFields:{
                        withCredentials:true
                    },
                    success: function (data) {
                        if(data.state){
                            TOAST.success("成功", ' ', 2);
                            window.location.reload();
                        }else{
                            return TOAST.wran("失败", ' ', 2);
                        }
                    }
                })
            }
        }
        if (e == 'ugood') {
            $.ajax({
                url: '/forum/highlight',
                type: "POST",
                data: {
                    forum_id: forumId,
                    highlight: 0
                },
                xhrFields:{
                    withCredentials:true
                },
                success: function (data) {
                    if(data.state){
                        TOAST.success("成功", ' ', 2);
                        window.location.reload();
                    }else{
                        return TOAST.wran("失败", ' ', 2);
                    }
                }
            })
        }
        if (e == 'top') {
            var top = confirm('是否置顶?');
            if(top){
                $.ajax({
                    url: '/forum/top',
                    type: 'POST',
                    data: {
                        forum_id: forumId,
                        top: 1
                    },
                    xhrFields:{
                        withCredentials:true
                    },
                    success: function (data) {
                        if(data.state){
                            TOAST.success("成功", ' ', 2);
                            window.location.reload();
                        }else{
                            return TOAST.wran("失败", ' ', 2);
                        }
                    }
                })
            }
        }

        if (e == 'utop') {
            $.ajax({
                url: '/forum/top',
                type: 'POST',
                data: {
                    forum_id: forumId,
                    top: 0
                },
                xhrFields:{
                    withCredentials:true
                },
                success: function (data) {
                    if(data.state){
                        TOAST.success("成功", ' ', 2);
                        window.location.reload();
                    }else{
                        return TOAST.wran("失败", ' ', 2);
                    }
                }
            })
        }

        if (e == 'delete') {
            var delet = confirm('是否删除该帖子?');
            if(delet) {
                $.ajax({
                    url: '/forum/remove',
                    type: 'POST',
                    data: {
                        forum_id: forumId,
                    },
                    xhrFields:{
                        withCredentials:true
                    },
                    success: function (data) {
                        if(data.state){
                            TOAST.success("成功", ' ', 2);
                            window.location.href = '/home?label_id=' + labelID + '#forum_page';
                        }else{
                            return TOAST.wran("失败", ' ', 2);
                        }
                    }
                })
            }
        }
        if (e == 'review') {
            var review = confirm('是否通过该帖子?');
            var label_id = $('.labels').val();
            if(review) {
                $.ajax({
                    url: '/forum/apply_dispose',
                    type: 'POST',
                    data: {
                        forum_id: forumId,
                        approve: 1,
                        label_id:label_id
                    },
                    xhrFields:{
                        withCredentials:true
                    },
                    success: function (data) {
                        if(data.state){
                            TOAST.success("成功", ' ', 2);
                            window.location.reload();
                        }else{
                            return TOAST.wran("失败", ' ', 2);
                        }
                    }
                })
            }
        }
        if (e == 'reject') {
            var reject = confirm('是否拒绝该帖子发布?');
            var label_id = $('.labels').val();
            if(reject) {
                $.ajax({
                    url: '/forum/apply_dispose',
                    type: 'POST',
                    data: {
                        forum_id: forumId,
                        approve: 0,
                        label_id:label_id
                    },
                    xhrFields:{
                        withCredentials:true
                    },
                    success: function (data) {
                        if(data.state){
                            TOAST.success("成功", ' ', 2);
                            window.location.href = '/home?label_id=' + labelID + '#forum_page';
                        }else{
                            return TOAST.wran("失败", ' ', 2);
                        }
                    }
                })
            }
        }
    }

    $('#huifu-list').on('click', '.delete', function () {
        var replyID = $(this).attr('data-id');
        var delet = confirm('是否删除该评论');
        if(delet) {
            $.ajax({
                url: '/forum/reply_remove',
                type: 'POST',
                data: {
                    reply_id: replyID
                },
                xhrFields:{
                    withCredentials:true
                },
                success: function (data) {
                    if(data.state){
                        TOAST.success('删除成功', ' ', 2);
                        window.location.reload();
                    }else{
                        TOAST.warn(data.errormsg, ' ', 2);
                    }

                }
            })
        }
    });

    $('body').on('click','.user-space' ,function () {
        var userID = $(this).attr('user-id');
        if (!userID) {
            userID = $(this).next().text();
        }
        window.location.href = '/home?user_id='+userID+'#forum_space'
    });

    function progressHandlingFunction(e) {
        if (e.lengthComputable) {
            var percent = e.loaded/e.total*100;
            $('.progress').html(percent.toFixed(2));
        }
    };
    $('body').on('change', '#mupload', function () {
        $(this).before("<div class=\"weui-uploader__file-content progress\">0%</div>");
        var formDate = new FormData();
        formDate.append('0', $('#mupload')[0].files[0]);
        $.ajax({
            url: '/upload/phoneimg',
            type: 'POST',
            cache: false,
            data: formDate,
            xhrFields:{
                withCredentials:true
            },
            xhr: function () {
                myXhr = $.ajaxSettings.xhr();
                if(myXhr.upload){
                    myXhr.upload.addEventListener('progress',progressHandlingFunction, false);
                }
                return myXhr;
            },
            processData: false,
            contentType: false,
            success: function (data) {
                if (data.state) {
                    var imgUrl = data.data.url;
                    var ed = $('#m-editor-content');
                    ed.append("<img src='"+ imgUrl + "' />");
                    $('.progress').remove();
                    return
                }
                TOAST.wran(data.errormsg, '失败', 3);
                $('.progress').remove();
            },
            error: function (err) {
                return TOAST.wran("网络错误，请重试", '失败', 3);
            }
        });
    });
    $.ajax({
        url:'/forum/label_list',
        type:'POST',
        xhrFields:{
            withCredentials:true
        },
        success:function (data) {
            if(data.state){
                var labelID = $('.labelname').next().text();
                var datas = data.data.list;
                for (var i=0;i<datas.length;i++){
                    if(datas[i].label_id != labelID){
                        $('.labels').append("<option value=" + datas[i].label_id + ">" + datas[i].cn + "</option>");
                    }
                }
            }
        }
    });

    function ajax_page(num) {
        TOAST.load('加载中', ' ', 10);
        $.ajax({
            url: '/forum/getinfo',
            type: 'POST',
            data: {
                page: num,
                forum_id: postID,
                replys: 1
            },
            xhrFields:{
                withCredentials:true
            },
            success: function (data) {
                if (num > 1) {
                    $('#article-detail').hide();
                } else {
                    $('#article-detail').show();
                }
                if (data.state) {
                    TOAST.stop();
                    var datas = data.data.info;
                    var page = data.page;
                    createDom(datas, '#huifu-list');
                    $('#page-btn').html(page);
                    document.body.scrollTop=0;
                    document.documentElement.scrollTop=0;
                    return;
                } else {
                    TOAST.wran(data.errormsg, ' ', 1);
                }
            }
        })
    }
    // 分享
    $('#forum-detail').on('bc-info-success', function() {
        document.title = $('#post-title').find('title').text();
        var srcUrl = $('#post-ava').attr('src');
        $('body').before(`<div class="hidden"><img src="${srcUrl}" /></div>`);
    });

</script>
